//
//  NSError+HttpClient.m
//  ITV
//
//  Created by inphase on 17/5/15.
//  Copyright © 2017年 inphase. All rights reserved.
//

#import "NSError+HttpClient.h"
#import <MJExtension.h>

@implementation NSError (HttpClient)

-(NSData *) errorData {
    
    return [self userInfo][@"com.alamofire.serialization.response.error.data"] ;
}


-(NSString *)errorString {
    
    return [[NSString alloc]initWithData:[self errorData] encoding:NSUTF8StringEncoding];
}

-(id)errorInfor {
    
    NSError *error = nil;
    if ([self errorData]) {
        id obj = [NSJSONSerialization JSONObjectWithData:[self errorData]
                                                 options:NSJSONReadingMutableContainers error:&error];
        
        
        if (!error) {
            return obj;
        }
    }
    
    return nil;
}

@end
